<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>邮箱验证</title>
	</head>
	<body>
		<input type="button" value="邮箱验证" onclick="judge();" />
		<script type="text/javascript">
			function judge(){
			var po1=prompt("请输入正确的邮箱地址","susan@sohu.com");
			if(po1==""){
				alert("邮箱不能为空！");
			}
				else if(po1.indexOf("@")==-1||po1.indexOf(".")==-1){
				alert("邮箱地址必须包含@和.")
			}else if(po1.indexOf("@")!=-1&&po1.indexOf(".")!=-1){
				var shu=po1.indexOf("@");
				var name=po1.substring(0,shu);
				alert("邮箱格式正确，邮箱名字为"+name);
			}
		}
		</script>
	</body>
</html>
